/**
 * 
 */
package graph;

import java.util.List;

import util.CommonFormatter;

/**
 * @author xiaohui
 * 
 *         To ensure correct orientation, vertices are ordered on their id.
 */
public class NetworkPoint extends GraphNode implements Comparable {

	private double ratioFromNode; // 0 <= r <= 1
	private int edgeId;

	// public ELocation(int id, int edgeId, double ratioFromNode,
	// double distFromNode) {
	// super(id);
	// this.edgeId = edgeId;
	// this.ratioFromNode = ratioFromNode;
	// this.distFromNode = distFromNode;
	//
	// }

	public NetworkPoint(int id, int edgeId, double ratioFromNode) {
		// meaning there is no coordinates
		super(id, -1, -1);
		this.edgeId = edgeId;
		this.ratioFromNode = ratioFromNode;
	}

	public NetworkPoint(int id, int edgeId, double ratioFromNode, double x,
			double y) {
		super(id, x, y);
		this.edgeId = edgeId;
		this.ratioFromNode = ratioFromNode;
	}

	// public String toString() {
	// return "ELoc at edge " + edgeId + " " + offsetFromNode + " "
	// + offsetToNode;
	// }
	public String toString() {
		if (this.x == -1 && this.y == -1)
			return "np: eid-" + edgeId + ", offset-"
					+ CommonFormatter.format(ratioFromNode);
		else
			return "np: eid-" + edgeId + ", offset-"
					+ CommonFormatter.format(ratioFromNode) + " ("
					+ CommonFormatter.format(this.x) + ","
					+ CommonFormatter.format(this.y) + ")";
	}

	@Override
	public int compareTo(Object obj) {
		NetworkPoint eloc1 = (NetworkPoint) obj;
		if (this.ratioFromNode < eloc1.ratioFromNode) {
			return -1;
		} else if (this.ratioFromNode > eloc1.ratioFromNode) {
			return 1;
		}
		return 0;
	}

	public double getRatioFromNode() {
		return ratioFromNode;
	}

	public void setRatioFromNode(double ratioFromNode) {
		this.ratioFromNode = ratioFromNode;
	}

	public int getEdgeId() {
		return edgeId;
	}

	public void setEdgeId(int edgeId) {
		this.edgeId = edgeId;
	}
//
//	public double getDistFromNode() {
//		return distFromNode;
//	}

//	public void setDistFromNode(double distFromNode) {
//		this.distFromNode = distFromNode;
//	}

	public double getX() {
		return x;
	}

	public void setX(double x) {
		this.x = x;
	}

	public double getY() {
		return y;
	}

	public void setY(double y) {
		this.y = y;
	}

}
